package com.wenjiang.controller;

import com.wenjiang.common.dto.SearchDetailParam;
import com.wenjiang.common.dto.SearchGoodByTypeParam;
import com.wenjiang.common.lang.Result;
import com.wenjiang.service.GoodSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
public class MallSearchController {

    @Autowired
    GoodSearchService goodSearchService;


    //获取热门搜索关键字
    @RequestMapping("/hotKeys")
    public  Object getSearchHotKey(){
        Result keyWord = goodSearchService.getHotKeyWord();

        return  keyWord;
    }


    //根据关键字查询商品
    @RequestMapping("/searchGood/{KeyWord}")
    public Object searchGoodByKeyword(@PathVariable(name = "KeyWord")String keyword){

        Result result = goodSearchService.searchGoodByName(keyword);

        return result;

    }

    //搜索商品详情信息
    @RequestMapping("/searchGoodDetail")
    public  Object searchGoodDetail(@RequestBody SearchDetailParam searchDetailParam){
        Result result = goodSearchService.searchGoodDetail(searchDetailParam);

        return result;
    }


    //根据商品类型id
    @RequestMapping("/searchGoodByType")
    public  Object searchGoodByType(@RequestBody SearchGoodByTypeParam goodByTypeParam){
        Result result = goodSearchService.searchGoodByType(goodByTypeParam);
        return  result;
    }
}
